<?php
/**
 * Created by PhpStorm.
 * User:王加明
 * Date: 2017-04-13
 * Time: 下午 1:40
 */
namespace app\hongyanche\controller;
class Maintain{
    //获取类别列表
    public function label_list()
    {
        $res = model('maintain')->label_list();
        return json($res);
    }
    //被动获取车辆服务详细信息
    function service_station(){

    }
    //获取用户位置信息
//    function station_list(){
//        //获取页面数据
//        $data = [
//            'lng' => input('lng'),//经度
//            'lat'  => input('lat'),//纬度
//            'page'           =>input('page'),
//            'maxPerPage'    =>input('maxPerPage'),
//            'cust_type'  =>input('cn_code')
//        ];
//        //调用模型，并返回服务站信息
//        $res = model('Maintain')->station_list($data);
//        return json($res);
//    }
    function station_list(){
        //获取页面数据
        $data = [
            'province' => input('province'),//经度
            'city'  => input('city'),//纬度
            'area'           =>input('area'),
            'cust_type'  =>input('cn_code')
        ];
        //调用模型，并返回服务站信息
        $res = model('Maintain')->station_list($data);
        return json($res);
    }
    //获取服务类型
    function service_type(){
        $res = model('maintain')->service_type();
        return json($res);
    }
    //定时器
    function timer(){
        $res = model('Maintain')->timer();
        return json($res);
    }


    //预约申请
    function reserve_apply(){
        $apply_id = input('apply_id');
        $res = model('Maintain')->reserve_apply($apply_id);
        return json($res);
    }
    //用户编辑预约信息
    function reserve_create(){
        $data = [
            'customer_id' => input('customer_id'),
            'ci_code'     => input('ci_code'),
            'type'        => input('type'),
            'apply_time' => input('apply_time'),
            'out'         =>input('out')
        ];
        $res = model('Maintain')->reserve_create($data);
        return json($res);
    }
    //取消预约
    function reserve_cancel(){
        $apply_id = input('apply_id');
        $res = model('Maintain')->reserve_cancel($apply_id);
        return json($res);
    }
    //预约列表
    function reserve_list(){
        $filter = [
            'page'           =>input('page'),
            'maxPerPage'    =>input('maxPerPage'),
            'keywords'      =>input('keywords')
        ];
        $res = model('maintain')->reserve_list($filter);
        return json($res);
    }


    //创建新的车辆信息
    function vehicle_create(){
        $data=[
            'vin'=> input('vin'),
            'uname'   =>input('uname'),
            'vehicle_license_province'=> input('vehicle_license_province'),
            'vehicle_license_number'=> input('vehicle_license_number'),
            'role'=>input('role'),
            'vehicle_brand'=> input('vehicle_brand'),
            'driving_card'=> input('driving_card')
        ];
        $res = model('Maintain')->vehicle_create($data);
        return json($res);
    }
   /* //编辑车辆信息
    function vehicle_modify(){
        $key = input('key');
        $content = input('content');
        $customer_id = input('customer_id');
        $res = model('Maintain')->vehicle_modify($key,$content,$customer_id);
        return json($res);
    }*/
    //车辆信息列表
    function vehicle_list(){
        $filter = [
            'page'           =>input('page'),
            'maxPerPage'    =>input('maxPerPage'),
            'keywords'      =>input('keywords'),
        ];
        $res = model('Maintain')->vehicle_list($filter);
        return json($res);
    }
    function vehicle_remove(){
        $customer_id=input('customer_id');
        $res = model('maintain')->vehicle_remove($customer_id);
        return json($res);
    }


    //创建评论
    function comment_create(){
        $unit_id = input('unit_id');
        $res = model('maintain')->comment_create($unit_id);
        return json($res);
    }
    //编辑评论
    function comment_modify(){
        $data = [
            'comment_id' => input('comment_id'),
            'content' => input('content'),
            'pid' => input('pid'),
            'unit_id' => input('pid')
        ];
        $res = model('maintain')->comment_edit($data);
        return $res;
    }
    //删除评论
    function comment_remove(){
        $comment_id = input('comment_id');
        $res = model('maintain')->comment_remove($comment_id);
        return json($res);
    }


    //预约车辆的驾驶人员信息
    function customer_info(){
        $res = model('Maintain')->customer_info();
        return json($res);
    }


    //用户预约列表
   /* function all_list(){
        $res = model('maintain')->all_list();
        return json($res);
    }*/


    //创建订单
    //订单详情
    //订单列表

    //---------------------车联网----------------------
    //获取车辆信息
    public function getcarInfo()
    {
        $data['vhcle'] = input('vhcle');
        $res = model('maintain')->getCarInfo($data);
        return json($res);
    }

    //获取车辆轨迹
    public function gettrace()
    {
        $data['vhcle'] = input('vhcle');
        $data['start'] = input('start');
        $data['end'] = input('end');
        $res = model('maintain')->getTrace($data);
        return json($res);
    }

    //获取车辆位置
    public function getlocate()
    {
        $data['vhcle'] = input('vhcle');
        $res = model('maintain')->getLocate($data);
        return json($res);
    }
    //车辆里程油耗
    public function getconsumption()
    {
        $data['vhcle'] = input('vhcle');
        $data['start'] = input('start');
        $data['end'] = input('end');
        $res = model('maintain')->getConsumption($data);
        return json($res);
    }

}